<?php

class DbMysql
{

	/**
	 * @var array of DbMysql instance
	 */
	protected static $_inst = array();

	/**
	 * @var string
	 */
	protected $_name = null;

	/**
	 * configuration
	 * @var array
	 */
	protected $_config = array();

	/**
	 * protect constructor to prevent explicit instance
	 * @return void
	 */
	protected function __construct()
	{
		
	}
	
	/**
	 * magic method 
	 */
	public function __toString()
	{
		return $this -> _name;
	}

	/**
	 * @param string $name
	 * @param mixed $default
	 * @return mixed
	 */
	public function getConfig($name, $default = null)
	{
		return isset($this -> _config[$name]) ? $this -> _config[$name] : $default;
	}

	/**
	 * get mysql
	 */
	static public function inst($name = null)
	{
		if (null == $name)
		{
			$name = 'default';
		}
		return isset(self::$_inst[$name]) ? self::$_inst[$name] : new Db_Adapter_Mysql($name);
	}

}
